﻿using DAL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace BLL
{
   public class DriverBLL
    {
        DriverDAL drivedal = new DriverDAL();

        #region 显示驾驶员信息
        /// <summary>
        /// 显示驾驶员信息
        /// </summary>
        /// <param name="drive"></param>
        /// <returns></returns>
        public List<DriverQueryModel> Getdrivrmodel(DriverMODEL drive)
        {
            return drivedal.Getdrivrmodel(drive);
        }
        #endregion

        #region 添加驾驶员信息
        /// <summary>
        /// 添加驾驶员信息返回-1 重复添加，返回1 添加成功，返回0 添加失败
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Getdriver_add(DriverMODEL model)
        {
            if (drivedal.Getdriver_name(model.Name))
            {
                return -1;
            }
            int result = drivedal.Getdriver_add(model);
            if (result > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
        #endregion

        #region 删除,如果返回-1；用户已删除，返回1，删除成功，返回0 删除失败
        /// <summary>
        /// 删除,如果返回-1；用户已删除，返回1，删除成功，返回0 删除失败
        /// </summary>
        /// <param name="truckid"></param>
        /// <returns></returns>
        public int Getdrive_delete(int truckid)
        {
            DriverMODEL del = drivedal.Getdrive_byid(truckid);
            if (del.IsDelete == 0)
            {
                return -1;
            }
            int id = drivedal.Getdrive_delete(truckid);
            if (id > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
        #endregion

        #region 根据ID查询驾驶员信息
        /// <summary>
        /// 根据ID查询驾驶员信息
        /// </summary>
        /// <param name="driverid"></param>
        /// <returns></returns>
        public DriverMODEL Getdrive_byid(int driverid)
        {
            return drivedal.Getdrive_byid(driverid);
        }
        #endregion

        #region 修改用户信息
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="driverinfo"></param>
        /// <returns></returns>
        public int getdriver_Update(DriverMODEL driverinfo)
        {

            return drivedal.getdriver_Update(driverinfo);
        }
        #endregion

        #region 驾驶员绑定车辆信息
        /// <summary>
        /// 显示车辆信息
        /// </summary>
        /// <param name="truck"></param>
        /// <returns></returns>
        public List<TruckinfoModel> Gettruckinfo(TruckMODEL truck)
        {
            return drivedal.Gettruckinfo(truck);
        }
        #endregion

        /// <summary>
        /// 绑定显示
        /// </summary>
        /// <param name="driverid"></param>
        /// <returns></returns>
        public int GetBindCount(int driverid)
        {
            return drivedal.GetBindCount(driverid);
        }
        }
}
